﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace _MyTestProject {
    public class TestScene {

        [Fact]
        public void TestGetModelView () {
            var wld = new World ();
            var proj = new Transform (new float[]{1,0,0,0,
                                                  0,2,0,0,
                                                  0,0,3,0,
                                                  0,0,0,1});
            var cam = new Camera ();
            cam.SetTranslation (1, 1, 1);
            cam.SetGeneric (proj);

            var nod = new Group ();
            nod.SetTranslation (1, 2, 3);

            wld.SetActiveCamera (cam);
            wld.AddChild (cam);
            wld.AddChild (nod);

            var expected = new float[] {1,0,0,0,
                                        0,1,0,1,
                                        0,0,1,2,
                                        0,0,0,1};
            var mv = nod.ModelViewMatrix;

            Assert.Equal (expected, mv.Matrix);
        }


        [Fact]
        public void TestGetModelViewProjection () {
            var wld = new World ();

            var proj = new Transform (new float[]{1,0,0,0,
                                                  0,2,0,0,
                                                  0,0,3,0,
                                                  0,0,0,1});
            var cam = new Camera ();
            cam.SetTranslation (1, 1, 1);
            cam.SetGeneric (proj);

            var nod = new Group ();
            nod.SetTranslation (1, 2, 3);

            wld.SetActiveCamera (cam);
            wld.AddChild (cam);
            wld.AddChild (nod);

            var expected = new float[] {1,0,0,0,
                                        0,2,0,2,
                                        0,0,3,6,
                                        0,0,0,1};
            var mvp = nod.ModelViewProjectionMatrix;

            Assert.Equal (expected, mvp.Matrix);
        }

    }
}
